#include "RingQueue.hpp"
using namespace RingQueueModule;
int data = 0;
void* Consumer(void* arg)
{
    RingQueue<int>* rq = (RingQueue<int>*)arg;
    while(true)
    {
        int data;
        rq->Pop(&data);
        std::cout<<"消费一个数据:"<<data<<std::endl;
    }
}
void* Productor(void* arg)
{
    RingQueue<int>* rq  = (RingQueue<int>*)arg;
    while(true)
    {
        sleep(1);
        rq->EQueue(data);
        std::cout<<"生产一个数据:"<<data<<std::endl;
        data++;

    }
}
int main()
{
    RingQueue<int>* rq = new RingQueue<int>(5);
    pthread_t tid1;
    pthread_create(&tid1, nullptr, Consumer, (void*)rq);
    pthread_t tid3;
    pthread_create(&tid3, nullptr, Consumer, (void*)rq);
    pthread_t tid2;
    pthread_create(&tid2, nullptr, Productor, (void *)rq);
    pthread_t tid4;
    pthread_create(&tid4, nullptr, Productor, (void*)rq);
    while(true);
    return 0;
}